/*
 * @Descripttion: 
 * @version: 
 * @Author: hutao
 * @Date: 2023-04-23 14:50:21
 * @LastEditors: hutao
 * @LastEditTime: 2023-05-12 09:27:17
 */
export default {
  state: {
    // "企业名称",
    enterpriseName: "星环视界智能科技",
    // "基本请求路径",
    baseUrl: "",
    /** 代理地址 */
    proxy: "",
    /** 授权 */
    grantedPolicies: {},
    /** 部门人员 */
    organizationUsers: [],
    /** 循环规则 */
    baseCron: [],
    /** 部门 */
    organizationUnit: [],
    /** 人员 */
    users: [],
    /** 严重等级 */
    severityLevel: [],
    /** 资产分类 */
    assetTypes: [],
    /** 位置 */
    positions: [],
    /** 分组 */
    grids: []
  },
  getters: {
    getBaseData: (state: any) => (name: string) => state[name]
  },
  mutations: {
    setBaseData(state: any, baseData: any) {
      for (const key in baseData) {
        if (baseData.hasOwnProperty(key) && !/(^\?)|(^？)/.test(key)) {
          let element: string = baseData[key];
          if (/^baseUrl/.test(key)) {
            element = element.replace(/\/$/g, "");
          }
          state[key] = element;
        }
      }
    },
    setBaseDataApi(state: any, payload: { key: string; value: any }) {
      state[payload.key] = payload.value;
    }
  },
  actions: {}
};
